package cn.itsource.order.domain;

import cn.itsource.basic.domain.OrderSn;
import cn.itsource.basic.util.GetUserInfoUtil;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;

import javax.persistence.Id;
import java.math.BigDecimal;
import java.util.Date;

@Data
public class TOrderAdopt implements OrderSn {
    @Id
    private Long id;
    private String digest;
    private Integer state;
    private BigDecimal price;
    private String orderSn;
    private String paySn;
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date lastPayTime;
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date lastConfirmTime;
    private Long petId;
    private Long userId;
    private Long shopId;
    private Long addressId;

    //设置订单的基础信息方法
    public void init(OrderDTO orderDTO) {
        this.petId = orderDTO.getPetId();
        this.price = orderDTO.getRealPayMoney();
        this.state = 0;
        this.lastConfirmTime = new Date();
        this.userId = GetUserInfoUtil.getUserId();
        this.orderSn = this.createOrderSn();
    }
}
